<!DOCTYPE html>
<html lang="cn" xmlns:th="http://www.thymeleaf.org"
      th:replace="pages/common/main :: layout(~{}, ~{::section}, ~{}, ~{::script})">
    <section>

        <div class="layui-card">
            <div class="layui-card-body">
                <form name="menu" class="layui-form layui-form-pane" lay-filter="FORM">
                    <div class="layui-form-item">
                        <label class="layui-form-label" for="oldPassword">旧密码</label>
                        <div class="layui-input-block">
                            <input type="password" name="oldPassword" id="oldPassword" class="layui-input"
                                   autocomplete="off">
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <label class="layui-form-label" for="newPassword">新密码</label>
                        <div class="layui-input-block">
                            <input type="password" name="newPassword" id="newPassword" class="layui-input"
                                   autocomplete="off">
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <label class="layui-form-label" for="repeatPassword">确认新密码</label>
                        <div class="layui-input-block yak-radios">
                            <input type="password" name="repeatPassword" id="repeatPassword" class="layui-input"
                                   autocomplete="off">
                        </div>
                    </div>

                    <div class="layui-form-item layui-input-block">
                        <button type="submit" class="layui-btn" lay-submit lay-filter="form-submit">提交</button>
                    </div>

                </form>
            </div>
        </div>

    </section>


    <script>

        layui.use(['form', 'admin', 'ax'], function () {

            var form = layui.form
                , $ax = layui.ax;

            form.on('submit(form-submit)', function (data) {
                var ajax = new $ax(Kong.ctxPath + "/sys/admin/reset-pwd", function (res) {
                    Kong.success("修改成功!");
                    var index = parent.layer.getFrameIndex(window.name);
                    parent.layer.close(index)
                }, function (res) {
                    Kong.error(res.msg);
                });
                ajax.setMethod("post");
                ajax.setData(data.field);
                ajax.send();
                return false;
            })

        })

    </script>

</html>